package com.jet.core.model.query;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
@ApiModel
public class PageQuery implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * example 设置文档默认值
     */
    @ApiModelProperty(value = "每页大小，默认10", example = "10")
    private long pageSize = 10;

    /**
     * example 设置文档默认值
     */
    @ApiModelProperty(value = "当前页，默认1", example = "1")
    private long pageIndex = 1;

    @ApiModelProperty(value = "排序")
    private List<OrderItem> orders;

    private long offset;

    public long getOffset() {
        long pageIndex = this.pageIndex - 1;
        return pageIndex * pageSize;
    }
}
